package com.mvc.util;

import com.mvc.annotion.Component;
import com.mvc.annotion.Resource;

import java.sql.SQLException;

/**
 * @Description
 * @Author xsd
 * @Date 2020/6/7 12:32
 */
@Component
public class TransactionUtil {
    @Resource
    private ConnectionUtils connectionUtils;

    public static void beginTransaction() throws SQLException {
        CurrentCon.getCon().getCurrentThreadConn().setAutoCommit(false);
    }

    public static void commit() throws SQLException {
        CurrentCon.getCon().getCurrentThreadConn().commit();
    }

    public static void rollback() throws SQLException {
        CurrentCon.getCon().getCurrentThreadConn().rollback();
    }
}
